package com.aglhz.nature.adapter;

import java.util.List;



import com.aglhz.nature.R;
import com.aglhz.nature.modle.item.ShopListData;
import com.squareup.picasso.Picasso;

import android.content.Context;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

public class CopyOfShopList2Adapter extends BaseAdapter{
	public List<ShopListData>mData;
    public Context context;
          
	public CopyOfShopList2Adapter(List<ShopListData> mData, Context context) {
		super();
		this.mData = mData;
		this.context = context;
	}
	
	
	
	
	
	
	@Override
	public int getCount() {
		return mData.size();
	}
	@Override
	public Object getItem(int position) {
		return mData.get(position);
	}
	@Override
	public long getItemId(int position) {
		return position;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		 ViewHolder viewHolder; 
			if(null==convertView){			
				  convertView = LayoutInflater.from(context).inflate(R.layout.item_shoplist, null); 
				  viewHolder = new ViewHolder();
				  viewHolder.item_shoplist_imageView = (ImageView) convertView.findViewById(R.id.item_shoplist_imageView); 
				  viewHolder.item_shoplist_name= (TextView) convertView.findViewById(R.id.item_shoplist_name); 
				  viewHolder.item_shoplist_introduction= (TextView) convertView.findViewById(R.id.item_shoplist_introduction); 
				  viewHolder.item_shoplist_price= (TextView) convertView.findViewById(R.id.item_shoplist_price); 
				  convertView.setTag(viewHolder); 
			}else{
				viewHolder = (ViewHolder) convertView.getTag(); 
			}
			//设置图片
			
				  String imgUrl = mData.get(position).getPictureURL();
				//picasso加载网络图片
				   Picasso.with(context)  
				   .load(imgUrl)  	    	               
				   .into(viewHolder.item_shoplist_imageView) ;
	   
			//设置文字
			viewHolder.item_shoplist_name.setText(mData.get(position).getName());
			viewHolder.item_shoplist_introduction.setText(mData.get(position).getIntroduction());
			viewHolder.item_shoplist_name.setText("月成交"+mData.get(position).getNumber()+"笔 "+"  评价   ");
			viewHolder.item_shoplist_name.setText(mData.get(position).getPrice());
			
//			int screenWidth = getScreenWidth();
//			GridView.LayoutParams p=new GridView.LayoutParams(screenWidth,screenWidth);
//			convertView.setLayoutParams(p);

			return convertView;
		}
		class ViewHolder 
		{  
		    public ImageView item_shoplist_imageView;
		    public TextView item_shoplist_name;
		    public TextView item_shoplist_introduction;
		    public TextView item_shoplist_price;
		} 
		
		/**
		 * 获取屏幕宽度
		 * 
		 * @return
		 */
		protected int getScreenWidth() {
			WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
			Display display = wm.getDefaultDisplay();
			return display.getWidth();
		}
	} 

